import React, { useState, useEffect } from 'react'
import { Table,Modal,Checkbox  } from 'antd'
import { Link } from "react-router-dom"

export default function MessagealertList(props) {

  const [selectedRowKeys, setSelectedRowKeys] = useState([])
  const [resdata, setResData] = useState([])

  const [pageSize, setPageSize] = useState(10)
  const [pageSizeNow, setPageSizeNow] = useState(1)

  // 第几次


  const columns = [
    {
      title: '消息类型',
      dataIndex: 'xiaoxileixing',
    },
    {
      title: '电子邮件',
      dataIndex: 'dianziyoujain',
    },
    {
      title: '站内消息',
      dataIndex: 'zhanleixiaoxi',
    },
    {
      title: '手机短信',
      dataIndex: 'shoujiduanxin',
    }
  ];

  const name = [
    '贷款审批通过提醒','贷款审批拒绝提醒','放款提醒','预警提醒','即将到期提醒','逾期提醒','还款提醒','结项提醒'
  ]

  const data = [];

  for (let i = 0; i < 8; i++) {
    data.push({
      key: i,
      xiaoxileixing: name[i],
      dianziyoujain:<span> <Checkbox defaultChecked/> <span>是否发送</span> <a > 编辑内容 </a> </span>,
      zhanleixiaoxi:<span> <Checkbox defaultChecked/> <span>是否发送</span> <a > 编辑内容 </a> </span>,
      shoujiduanxin:<span> <Checkbox defaultChecked/> <span>是否发送</span> <a > 编辑内容 </a> </span>,
    })
  }


  const getPage = (pageSizeNow, pageSize) => {
    console.log(typeof pageSizeNow);
    console.log(typeof pageSize);
    setPageSize(pageSize)
    setPageSizeNow(pageSizeNow)
  }



  const onSelectChange = selectedRowKeys => {
    console.log('selectedRowKeys changed: ', selectedRowKeys);
    setSelectedRowKeys(selectedRowKeys)
  };

  const rowSelection = {
    selectedRowKeys,
    onChange: onSelectChange,
    selections: [
      Table.SELECTION_ALL,
      Table.SELECTION_INVERT,
      Table.SELECTION_NONE,
      {
        key: 'odd',
        text: 'Select Odd Row',
        onSelect: changableRowKeys => {
          let newSelectedRowKeys = [];
          newSelectedRowKeys = changableRowKeys.filter((key, index) => {
            if (index % 2 !== 0) {
              return false;
            }
            return true;
          });
          setSelectedRowKeys(newSelectedRowKeys)
        },
      },
      {
        key: 'even',
        text: 'Select Even Row',
        onSelect: changableRowKeys => {
          let newSelectedRowKeys = [];
          newSelectedRowKeys = changableRowKeys.filter((key, index) => {
            if (index % 2 !== 0) {
              return true;
            }
            return false;
          });
          setSelectedRowKeys(newSelectedRowKeys)
        },
      },
    ],
  };


  return (
    <div>
      <Table columns={columns} dataSource={data}
        pagination={
          {
            total: data.length,
            showSizeChanger: true,
            showQuickJumper: true,
            showTotal: total => `共${Math.ceil(total / pageSize)}页/${total}条数据`,
            pageSizeOptions: ['10', '20', '30'],
            onChange: getPage,
          }
        }

      />
    </div>
  );
}



